#ifndef CMINIONNODE_H_INCLUDED
#define CMINIONNODE_H_INCLUDED

#include "CMinion.h"


class CStateGame;
class CBarSceneNode;

class CMinionNode : public CMinion
{
  public:
    //! Constructor
    CMinionNode(CStateGame *state, minionStats stats);

    //! Destructor
    virtual ~CMinionNode();

    //! Prepare the SceneNode (model) for displaying this minion
    bool prepareNode(ISceneNode *node, ITexture *texture);

    //! Overloaded prepareNode functino for testing purpose
    bool prepareNode();

    //! Set the position of the minion based on world coordinates
    void setPosition(f32 x, f32 z);

    //! Attack other minion
    // Returns 0 if the attack fails, and the damage of the attack if the attack
    // is sucessful. (Attack will never deals 0 damage)
    u16 attack(CMinionNode *target);

    //! Move
    bool move(vector3df& target);

    //! Face a target
    // Rotates the minion such that it will face the target vector
    void face(vector3df& target);

    //! Update HP
    u16 updateHp(u16 value, bool minus = true);

    //! Update per tick
    void update ();


    //! ---- Conditions methods ----
    //! Calculate if the 2 minion is in range
    bool IsInRange(CMinionNode *target, f32 Range);

    bool IsInRange(vector3df& targetPos, f32 Range);

    //! set the delay of the minion node
    void setDelay(u16 val);

    //! set the owner of the minion node
    void setOwner(COverlord* val);

    //! set the id of the minion node (for networking)
    void setID(u32 id);

    u16 getDelay();

    u32 getID();

    COverlord* getOwner();

    ISceneNode *getNode();
  protected:

  private:
    vector3df moveVector;

    vector3df destination;

    CBarSceneNode *hpBar;

    u16 delay;

    u16 ID;

    COverlord * owner;

    CStateGame *state;

    ISceneNode *node;
};

#endif // CMINIONNODE_H_INCLUDED
